
TARGET		= exam-1

CFLAGS		= -Wall -pipe -O2
LIBS		= -lobjc
SRCS		= $(foreach DIR, ., $(wildcard $(DIR)/*.mm))

OBJS		= $(SRCS:.mm=.o)		# object files
DEPS		= $(SRCS:.mm=.d)		# depend files

%.o : %.mm
	$(CXX) $(CFLAGS) -c $< -o $@

%.d : %.mm
	@$(SHELL) -ec '$(CC) -M $(CPPFLAGS) $< | sed '\''s/\($*\)\.o[ :]*/\1.o $@ : /g'\'' > $@; [ -s $@ ] || rm -f $@'

.PHONY : all clean distclean

all: $(TARGET) run

$(TARGET): $(OBJS)
	$(CXX) $(CFLAGS) -o $@ $^ $(INC) $(LIBS)

run :
	@./$(TARGET)

clean :
	rm -f $(TARGET) $(OBJS)

distclean : clean
	rm -f $(DEPS)

ifneq ($(MAKECMDGOALS),clean)
-include $(DEPS)
endif

